
#include "pr2000_support.h"
#if defined(__HOST_LINUX_SYSTEM__)
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/system.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/string.h>
#include <linux/list.h>
#include <asm/delay.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <linux/moduleparam.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#elif defined(__HOST_MICOM_SYSTEM__)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(STM32F10X_HD)
#include "stm32f10x.h"
#else
//#include "stm8s.h"
#endif

//#include "uart.h"
//#include "delay.h"
//#include "user_func.h"
#endif
#include "pr2000.h"
#include "pr2000_table.h"
#include "pr2000_func.h"
#include "pr2000_user_config.h"
#include "pr2000_ceqfunc.h"
#include "typedef.h"
#ifdef SUPPORT_CEQ
#define PR2000_CEQ_EST_COMP(x,y)        ((0x9600*x)/y)
#endif
int PR2000_ProcessCameraPlugIn(const int i2cFd
                               , const uint8_t slvAddr, void*pArg)
{
    int result = -1;
    _drvHost*pHost = (_drvHost*)pArg;
    _stPR2000_Isr*pstIsr = (_stPR2000_Isr*)&pHost->stPR2000_Isr;
    _stPR2000_Reg stReg;
    uint8_t u8RegMask;
    uint8_t u8RegData;
    enum _eCameraStandard cameraStandard;
    enum
    _eCameraResolution cameraResolution;
    enum _eVideoResolution videoResolution;
    int
    reJudge = 0;
    _stPR2000_VidStatusReg curStVidStatusReg;
#ifdef SUPPORT_CEQ
    _stPR2000_MeasureEqInfo stMeasureEqInfo;
#endif
    uint32_t tunnChromaPhase = 0;
    int chipInx = 0;
    Dbg(
        "\x25\x78\x2d\x50\x6c\x75\x67\x49\x6e\x4e\x75\x6d\x4a\x6f\x62\x53\x74\x65\x70\x3a\x25\x64" "\n"
        , slvAddr COMMA pstIsr->stJobProc.numJobStep);
#ifdef SUPPORT_PROC_SYSTEM
#ifdef SUPPORT_CEQ

    SET_STEP_BIT(pstIsr->stJobProc.numJobStep, pHost->stCEQInfo.stepBits);
#endif

#endif
    if(pstIsr->stJobProc.numJobStep == 0)
    {
        ErrorString(
            "\x49\x6e\x76\x61\x6c\x69\x64\x20\x6e\x75\x6d\x4a\x6f\x62\x53\x74\x65\x70" "\n")
        ;
        return(-1);
    }
    if(pstIsr->stJobProc.numJobStep == 1)
    {
        Print(
            "\x25\x78\x2d\x52\x65\x61\x64\x20\x73\x74\x64\x2f\x72\x65\x73\x6f\x6c\x2c\x20\x77\x72\x69\x74\x65\x20\x6d\x61\x6e\x20\x66\x6f\x72\x6d\x61\x74" "\n"
            , slvAddr);
        if(!DEFAULT_AUTODETECT_ENABLE)
        {
            switch(DEFAULT_CAMERA_STANDARD)
            {
                case SD
                        :
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_PVI;
                    }
                    break;
                case PVI:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_PVI;
                }
                break;
                case CVI:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_CVI;
                }
                break;
                case
                        HDA:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_HDA;
                    }
                    break;
                case HDT_OLD
                        :
                case HDT_NEW:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_HDT;
                }
                break;
                default:
                {
                    ErrorString(
                        "\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x63\x61\x6d\x65\x72\x61\x20\x73\x74\x61\x6e\x64\x61\x72\x64" "\n"
                    );
                }
                break;
            }
            switch(DEFAULT_CAMERA_RESOLUTION)
            {
                case camera_ntsc:
                {
                    pstIsr->stJobProc.
                    stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.
                    det_ifmt_res = DET_SD480i;
                }
                break;
                case camera_pal:
                {
                    pstIsr->stJobProc.stVidStatusReg
                    .b.det_ifmt_ref = DET_25Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res =
                        DET_SD576i;
                }
                break;
                case camera_1280x720p60:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.
                    det_ifmt_ref = DET_60Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD720p
                            ;
                }
                break;
                case camera_1280x720p50:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref
                        = DET_50Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD720p;
                }
                break;
                case
                        camera_1280x720p30:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_30Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD720p;
                    }
                    break;
                case
                        camera_1280x720p25:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD720p;
                    }
                    break;
                case
                        camera_1920x1080p30:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_30Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD1080p;
                    }
                    break;
                case
                        camera_1920x1080p25:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD1080p;
                    }
                    break;
#if defined(SUPPORT_EXTEND_HD_VIDEO_800P_RESOLUTION)
                case camera_1280x800p60:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref =
                        DET_60Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                }
                break;
                case
                        camera_1280x800p50:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_50Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
                case
                        camera_1280x800p30:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_30Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
                case
                        camera_1280x800p25:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
#elif defined(SUPPORT_EXTEND_HD_VIDEO_960P_RESOLUTION)
                case camera_1280x960p60:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref =
                        DET_60Hz;
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                }
                break;
                case
                        camera_1280x960p50:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_50Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
                case
                        camera_1280x960p30:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_30Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
                case
                        camera_1280x960p25:
                    {
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD960p;
                    }
                    break;
#endif
                default:
                {
                    pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                    pstIsr->
                    stJobProc.stVidStatusReg.b.det_ifmt_res = DET_HD720p;
                }
                break;
            }
            PR2000_ReadStdResol(
                i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &cameraStandard, &
                cameraResolution, &videoResolution);
            Print(
                "\x25\x78\x2d\x46\x69\x78\x20\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x5d" "\n"
                , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                videoResolution COMMA _strVideoResolution[videoResolution]);
        }
        else
        {
            PR2000_ReadStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                                cameraStandard, &cameraResolution, &videoResolution);
            Print(
                "\x25\x78\x2d\x52\x65\x61\x64\x20\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x5d" "\n"
                , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                videoResolution COMMA _strVideoResolution[videoResolution]);
        }
        Print(
            "\x25\x78\x2d\x53\x65\x74\x20\x6f\x6e\x6c\x79\x20\x53\x74\x52\x65\x73\x6f\x6c\x2c\x20\x45\x71\x47\x61\x69\x6e\x2c\x20\x43\x50\x68\x61\x73\x65\x52\x65\x66\x28\x6b\x65\x65\x70\x29\x2e\x2e\x2e" "\n"
            , slvAddr);
        if((result = PR2000_SetTblBrief(i2cFd, slvAddr, cameraStandard, videoResolution, 0, &
                                        pstIsr->stJobProc)) < 0)
        {
            ErrorString(
                "\x43\x61\x6e\x27\x74\x20\x73\x65\x74\x20\x74\x61\x62\x6c\x65\x20\x62\x72\x69\x65\x66" "\n"
            );
            return(result);
        }
        pstIsr->stJobProc.cntWait300MsecTime = 0;
#ifdef SUPPORT_CEQ
        memset(&pstIsr->stJobProc.stMeasureEqInfo, 0, sizeof(_stPR2000_MeasureEqInfo));
        pstIsr->stJobProc.numJobStep = 2;
#else
        pstIsr->stJobProc.numJobStep = 3;
#endif
        result = pstIsr->stJobProc.numJobStep;
        return(result);
    }
    if(pstIsr->stJobProc.
       numJobStep == 2)
    {
#ifdef SUPPORT_CEQ
        Print(
            "\x25\x78\x2d\x52\x65\x61\x64\x20\x67\x61\x69\x6e\x20\x26\x20\x53\x65\x74\x2e" "\n"
            , slvAddr);
        PR2000_GetDetGainStatus(i2cFd, slvAddr, &pstIsr->stJobProc.
                                stDetGainStatus);
        memcpy(&pstIsr->stJobProc.stFirstDetGainStatus, &pstIsr->
               stJobProc.stDetGainStatus, sizeof(_stPR2000_DetGainStatus));
        PR2000_GetEQGain(
            i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->stJobProc.
            stDetGainStatus, &stMeasureEqInfo);
        Print(
            "\x25\x78\x2d\x47\x65\x74\x20\x43\x6f\x6d\x70\x28\x30\x78\x25\x78\x2f\x25\x64\x6d\x29\x2c\x20\x41\x74\x74\x65\x6e\x28\x30\x78\x25\x78\x2f\x25\x64\x6d\x29\x2c\x20\x73\x65\x6c\x65\x63\x74\x2d\x3e\x28\x30\x78\x25\x78\x2f\x25\x64\x6d\x29" "\n"
            , slvAddr COMMA stMeasureEqInfo.vadcEqBandComp COMMA stMeasureEqInfo.distComp
            COMMA stMeasureEqInfo.vadcEqBandAtten COMMA stMeasureEqInfo.distAtten COMMA
            stMeasureEqInfo.vadcEqBand COMMA stMeasureEqInfo.dist);
        Print(
            "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x30\x78\x25\x30\x34\x78\x28\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x29\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
            , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
            stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
            COMMA((pstIsr->stJobProc.stDetGainStatus.comp2 != 0) ? PR2000_CEQ_EST_COMP(pstIsr->
                    stJobProc.stDetGainStatus.comp1, pstIsr->stJobProc.stDetGainStatus.comp2) : 0)COMMA
            pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.stDetGainStatus
            .comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA pstIsr->stJobProc.
            stDetGainStatus.atten2);
        PR2000_SetEQGain(i2cFd, slvAddr, &pstIsr->stJobProc.
                         stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &stMeasureEqInfo);
        memcpy(&
               pstIsr->stJobProc.stMeasureEqInfo, &stMeasureEqInfo, sizeof(
                   _stPR2000_MeasureEqInfo));
        pstIsr->stJobProc.cntWait300MsecTime = 0;
        if(!
           DEFAULT_AUTODETECT_ENABLE)
        {
            pstIsr->stJobProc.numJobStep = 40;
        }
        else
        {
            pstIsr->
            stJobProc.numJobStep = 3;
        }
        pstIsr->stJobProc.cntJobTry = 0;
        result = pstIsr->stJobProc.
                 numJobStep;
        return(result);
#else
        pstIsr->stJobProc.cntWait300MsecTime = 0;
        if(!DEFAULT_AUTODETECT_ENABLE)
        {
            pstIsr->
            stJobProc.numJobStep = 40;
        }
        else
        {
            pstIsr->stJobProc.numJobStep = 3;
        }
        pstIsr->stJobProc.
        cntJobTry = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
#endif
    }
    if(pstIsr->stJobProc.numJobStep == 3)
    {
        Print(
            "\x25\x78\x2d\x52\x65\x61\x64\x20\x73\x74\x64\x2f\x72\x65\x73\x6f\x6c\x2c\x20\x26\x20\x6c\x6f\x63\x6b" "\n"
            , slvAddr);
        PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
        if(((
                curStVidStatusReg.b.lock_gain) && (curStVidStatusReg.b.lock_clamp) && (
                curStVidStatusReg.b.lock_hperiod)) && ((pstIsr->stJobProc.stVidStatusReg.reg[0] &
                        0xff) == (curStVidStatusReg.reg[0] & 0xff)))
        {
            memcpy(&pstIsr->stJobProc.stVidStatusReg, &curStVidStatusReg, sizeof(
                       _stPR2000_VidStatusReg));
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->
            stJobProc.numJobStep = 4;
            pstIsr->stJobProc.cntJobTry = 0;
            result = pstIsr->stJobProc.
                     numJobStep;

        }
        else
        {
            if(pstIsr->stJobProc.cntJobTry++ >= 4)
            {
                ErrorString(
                    "\x43\x61\x6e\x27\x74\x20\x67\x65\x74\x20\x73\x74\x61\x62\x6c\x65\x20\x73\x74\x64\x2f\x72\x65\x73\x6f\x6c" "\n"
                );
                Print(
                    "\x25\x78\x2d\x46\x6f\x72\x63\x65\x6c\x79\x20\x53\x65\x74\x20\x61\x62\x6e\x6f\x72\x6d\x61\x6c\x20\x5b\x43\x56\x49\x20\x31\x30\x38\x30\x70\x32\x35\x5d" "\n"
                    , slvAddr);
                pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_CVI;
                pstIsr->
                stJobProc.stVidStatusReg.b.det_ifmt_ref = DET_25Hz;
                pstIsr->stJobProc.
                stVidStatusReg.b.det_ifmt_res = DET_HD1080p;
                pstIsr->stJobProc.cntWait300MsecTime = 0
                                                       ;
                pstIsr->stJobProc.numJobStep = 4;
                pstIsr->stJobProc.cntJobTry = 0;
                result = pstIsr->
                         stJobProc.numJobStep;

            }
            else
            {
                Error(
                    "\x25\x78\x2d\x43\x68\x61\x6e\x67\x65\x64\x20\x73\x74\x64\x2f\x72\x65\x73\x6f\x6c\x2c\x20\x72\x65\x63\x68\x65\x63\x6b\x2e" "\n"
                    , slvAddr);
                Print(
                    "\x25\x78\x2d\x4f\x6c\x64\x20\x56\x69\x64\x53\x74\x61\x74\x75\x73\x3a\x30\x78\x25\x30\x32\x78\x25\x30\x32\x78\x25\x30\x32\x78" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stVidStatusReg.reg[0]COMMA pstIsr->stJobProc.
                    stVidStatusReg.reg[1]COMMA pstIsr->stJobProc.stVidStatusReg.reg[2]);
                Print(
                    "\x25\x78\x2d\x43\x75\x72\x20\x56\x69\x64\x53\x74\x61\x74\x75\x73\x3a\x30\x78\x25\x30\x32\x78\x25\x30\x32\x78\x25\x30\x32\x78" "\n"
                    , slvAddr COMMA curStVidStatusReg.reg[0]COMMA curStVidStatusReg.reg[1]COMMA
                    curStVidStatusReg.reg[2]);
                memcpy(&pstIsr->stJobProc.stStartVidStatusReg, &
                       curStVidStatusReg, sizeof(_stPR2000_VidStatusReg));
                memcpy(&pstIsr->stJobProc.
                       stVidStatusReg, &curStVidStatusReg, sizeof(_stPR2000_VidStatusReg));
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 1;
                result = pstIsr->
                         stJobProc.numJobStep;
                return(result);
            }
        }
    }
    if(pstIsr->stJobProc.numJobStep == 4)
    {
        Print(
            "\x25\x78\x2d\x43\x68\x65\x63\x6b\x20\x48\x44\x41\x20\x6f\x72\x20\x43\x56\x49\x20\x37\x32\x30\x70\x36\x30\x2f\x35\x30\x2f\x33\x30\x2f\x32\x35\x20\x3f" "\n"
            , slvAddr);
        PR2000_ReadStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                            cameraStandard, &cameraResolution, &videoResolution);
        Print(
            "\x25\x78\x2d\x43\x75\x72\x20\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x5d" "\n"
            , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
            cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
            videoResolution COMMA _strVideoResolution[videoResolution]);
        if(((cameraStandard
             == HDA)) && ((cameraResolution == camera_1280x720p60) || (cameraResolution ==
                          camera_1280x720p50) || (cameraResolution == camera_1280x720p30) || (cameraResolution ==
                                  camera_1280x720p25)))
        {
            if((pstIsr->stJobProc.stVidStatusReg.b.det_chroma))
            {
                if((
                       pstIsr->stJobProc.stVidStatusReg.b.lock_chroma))
                {
                    Print(
                        "\x25\x78\x2d\x66\x69\x6e\x64\x20\x76\x61\x6c\x69\x64\x20\x66\x6f\x72\x6d\x61\x74\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x20\x72\x65\x4a\x75\x64\x67\x65\x3a\x25\x64\x5d" "\n"
                        , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                        cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                        videoResolution COMMA _strVideoResolution[videoResolution]COMMA pstIsr->
                        stJobProc.reJudgeStdResol);
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->
                    stJobProc.numJobStep = 10;
                    pstIsr->stJobProc.cntJobTry = 0;
                    result = pstIsr->stJobProc.
                             numJobStep;
                    return(result);
                }
                else
                {
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->
                    stJobProc.numJobStep = 5;
                    pstIsr->stJobProc.cntJobTry = 0;
                    result = pstIsr->stJobProc.
                             numJobStep;

                }
            }
            else
            {
                if(pstIsr->stJobProc.cntJobTry++ >= 4)
                {
                    Print(
                        "\x25\x78\x2d\x21\x64\x65\x74\x5f\x63\x68\x72\x6f\x6d\x61\x20\x2d\x3e\x20\x41\x73\x73\x75\x6d\x65\x20\x43\x56\x49\x2e" "\n"
                        , slvAddr);
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 30
                                                   ;
                    pstIsr->stJobProc.cntJobTry = 0;
                    result = pstIsr->stJobProc.numJobStep;

                }
                else
                {
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 4;
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
        }
        else
        {
            pstIsr->stJobProc.
            reJudgeStdResol = 0;
            Print(
                "\x25\x78\x2d\x63\x75\x72\x72\x65\x6e\x74\x20\x66\x6f\x72\x6d\x61\x74\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x20\x72\x65\x4a\x75\x64\x67\x65\x3a\x25\x64\x5d" "\n"
                , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                videoResolution COMMA _strVideoResolution[videoResolution]COMMA pstIsr->
                stJobProc.reJudgeStdResol);
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->
            stJobProc.numJobStep = 40;
            pstIsr->stJobProc.cntJobTry = 0;
            result = pstIsr->stJobProc.
                     numJobStep;

        }
    }
    if(pstIsr->stJobProc.numJobStep == 5)
    {
        Print(
            "\x25\x78\x2d\x48\x44\x41\x37\x32\x30\x70\x20\x43\x5f\x64\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b\x20\x63\x68\x65\x63\x6b\x2e\x20\x74\x75\x6e\x6e\x20\x63\x5f\x6c\x6f\x63\x6b\x2e" "\n"
            , slvAddr);
        Print(
            "\x25\x78\x2d\x64\x65\x66\x43\x68\x72\x6f\x6d\x61\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78\x2c\x20\x63\x6e\x74\x54\x75\x6e\x6e\x3a\x25\x78" "\n"
            , slvAddr COMMA pstIsr->stJobProc.defChromaPhase COMMA pstIsr->stJobProc.
            cntChromaLockTunn);
        PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
        if(
            (!curStVidStatusReg.b.det_chroma) || (pstIsr->stJobProc.cntChromaLockTunn >=
                    MAX_CNT_TUNN_CHROMALOCK))
        {
            Print(
                "\x25\x78\x2d\x43\x61\x6e\x27\x74\x20\x44\x65\x74\x20\x63\x68\x72\x6f\x6d\x61\x28\x25\x64\x29\x20\x6f\x72\x20\x4f\x76\x65\x72\x20\x63\x68\x65\x63\x6b\x20\x74\x69\x6d\x65\x28\x25\x64\x29\x20\x63\x68\x72\x6f\x6d\x61\x20\x6c\x6f\x63\x6b\x2e" "\n"
                , slvAddr COMMA curStVidStatusReg.b.det_chroma COMMA pstIsr->stJobProc.
                cntChromaLockTunn);
            tunnChromaPhase = pstIsr->stJobProc.defChromaPhase;
            stReg.reg =
                0x0146;
            u8RegData = ((tunnChromaPhase >> 16) & 0x1f) | 0x00;
            if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
               0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0147;
            u8RegData = (tunnChromaPhase >> 8) & 0xff;
            if((result
                = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0148;
            u8RegData = (tunnChromaPhase) & 0xff;
            if((result =
                    PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            Print(
                "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                , slvAddr COMMA tunnChromaPhase);
            {
                stReg.reg = 0x0154;
                u8RegData = 0x0e;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0154;
                u8RegData = 0x0f;
                if((result = PR2000_PageWrite(
                                 i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
            Print(
                "\x25\x78\x2d\x4e\x65\x78\x74\x20\x43\x68\x65\x63\x6b\x20\x43\x56\x49\x37\x32\x30\x70\x20\x43\x5f\x64\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b\x20\x63\x68\x65\x63\x6b" "\n"
                , slvAddr);
            {
                Print(
                    "\x25\x78\x2d\x46\x6f\x72\x63\x65\x6c\x79\x20\x53\x65\x74\x20\x28\x43\x56\x49\x29" "\n"
                    , slvAddr);
                pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_CVI;
                PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                                   cameraStandard, &cameraResolution, &videoResolution, &reJudge);
                reJudge = 1;
                pstIsr->
                stJobProc.reJudgeStdResol = reJudge;
                Print(
                    "\x25\x78\x2d\x53\x65\x74\x20\x6f\x6e\x6c\x79\x20\x53\x74\x52\x65\x73\x6f\x6c\x2c\x20\x45\x71\x47\x61\x69\x6e\x2c\x20\x43\x50\x68\x61\x73\x65\x52\x65\x66\x28\x6b\x65\x65\x70\x29\x2e\x2e\x2e" "\n"
                    , slvAddr);
                if((result = PR2000_SetTblBrief(i2cFd, slvAddr, cameraStandard, videoResolution, 0, &
                                                pstIsr->stJobProc)) < 0)
                {
                    ErrorString(
                        "\x43\x61\x6e\x27\x74\x20\x73\x65\x74\x20\x74\x61\x62\x6c\x65\x20\x62\x72\x69\x65\x66" "\n"
                    );
                    return(result);
                }
            }
            pstIsr->stJobProc.cntChromaLockTunn = 0;
            pstIsr->stJobProc.
            cntWait300MsecTime = 0;
            pstIsr->stJobProc.numJobStep = 6;
            pstIsr->stJobProc.cntJobTry =
                0;
            result = pstIsr->stJobProc.numJobStep;
            return(result);
        }
        else if(pstIsr->stJobProc.
                cntChromaLockTunn < MAX_CNT_TUNN_CHROMALOCK)
        {
            if((curStVidStatusReg.b.det_chroma) &&
               (curStVidStatusReg.b.lock_chroma))
            {
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr
                ->stJobProc.numJobStep = 10;
                pstIsr->stJobProc.cntJobTry = 0;
                result = pstIsr->stJobProc
                         .numJobStep;

            }
            else if((curStVidStatusReg.b.det_chroma) && (!curStVidStatusReg.b.lock_chroma))
            {
                tunnChromaPhase = (pstIsr->stJobProc.cntChromaLockTunn >> 1) + 1;
                tunnChromaPhase *= 40;
                if(pstIsr->stJobProc.cntChromaLockTunn & 1)
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase - tunnChromaPhase;
                }
                else
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase + tunnChromaPhase;
                }
                stReg.reg =
                    0x0146;
                u8RegData = ((tunnChromaPhase >> 16) & 0x1f) | 0x20;
                if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
                   0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0147;
                u8RegData = (tunnChromaPhase >> 8) & 0xff;
                if((result
                    = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0148;
                u8RegData = (tunnChromaPhase) & 0xff;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                Print(
                    "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                    , slvAddr COMMA tunnChromaPhase);
                {
                    stReg.reg = 0x0154;
                    u8RegData = 0x0e;
                    if((result =
                            PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                    stReg.reg = 0x0154;
                    u8RegData = 0x0f;
                    if((result = PR2000_PageWrite(
                                     i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                }
                pstIsr->stJobProc.cntChromaLockTunn++;
                pstIsr->stJobProc.
                cntWait300MsecTime = 1;
                pstIsr->stJobProc.numJobStep = 5;
                result = pstIsr->stJobProc.
                         numJobStep;
                return(result);
            }
        }
    }
    if(pstIsr->stJobProc.numJobStep == 6)
    {
        Print(
            "\x25\x78\x2d\x43\x56\x49\x37\x32\x30\x70\x20\x43\x5f\x64\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b\x20\x63\x68\x65\x63\x6b\x2e\x20\x74\x75\x6e\x6e\x20\x63\x5f\x6c\x6f\x63\x6b\x2e" "\n"
            , slvAddr);
        Print(
            "\x25\x78\x2d\x64\x65\x66\x43\x68\x72\x6f\x6d\x61\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78\x2c\x20\x63\x6e\x74\x54\x75\x6e\x6e\x3a\x25\x78" "\n"
            , slvAddr COMMA pstIsr->stJobProc.defChromaPhase COMMA pstIsr->stJobProc.
            cntChromaLockTunn);
        PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
        if(
            (!curStVidStatusReg.b.det_chroma) || (pstIsr->stJobProc.cntChromaLockTunn >=
                    MAX_CNT_TUNN_CHROMALOCK))
        {
            Error(
                "\x43\x61\x6e\x27\x74\x20\x44\x65\x74\x20\x63\x68\x72\x6f\x6d\x61\x28\x25\x64\x29\x20\x6f\x72\x20\x4f\x76\x65\x72\x20\x63\x68\x65\x63\x6b\x20\x74\x69\x6d\x65\x28\x25\x64\x29\x20\x63\x68\x72\x6f\x6d\x61\x20\x6c\x6f\x63\x6b\x2e" "\n"
                , curStVidStatusReg.b.det_chroma COMMA pstIsr->stJobProc.cntChromaLockTunn);
            tunnChromaPhase = pstIsr->stJobProc.defChromaPhase;
            stReg.reg = 0x0146;
            u8RegData = ((
                             tunnChromaPhase >> 16) & 0x1f) | 0x00;
            if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
               0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0147;
            u8RegData = (tunnChromaPhase >> 8) & 0xff;
            if((result
                = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0148;
            u8RegData = (tunnChromaPhase) & 0xff;
            if((result =
                    PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            Print(
                "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                , slvAddr COMMA tunnChromaPhase);
            {
                stReg.reg = 0x0154;
                u8RegData = 0x0e;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0154;
                u8RegData = 0x0f;
                if((result = PR2000_PageWrite(
                                 i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
            pstIsr->stJobProc.cntChromaLockTunn = 0;
            pstIsr->stJobProc.
            cntWait300MsecTime = 0;
            pstIsr->stJobProc.numJobStep = 30;
            pstIsr->stJobProc.cntJobTry
                = 0;
            result = pstIsr->stJobProc.numJobStep;
            return(result);
        }
        else if(pstIsr->stJobProc
                .cntChromaLockTunn < MAX_CNT_TUNN_CHROMALOCK)
        {
            if((curStVidStatusReg.b.det_chroma)
               && (curStVidStatusReg.b.lock_chroma))
            {
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 20;
                pstIsr->stJobProc.cntJobTry = 0;
                result = pstIsr->
                         stJobProc.numJobStep;

            }
            else if((curStVidStatusReg.b.det_chroma) && (!curStVidStatusReg.b.lock_chroma))
            {
                tunnChromaPhase = (pstIsr->stJobProc.cntChromaLockTunn >> 1) + 1;
                tunnChromaPhase *= 40;
                if(pstIsr->stJobProc.cntChromaLockTunn & 1)
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase - tunnChromaPhase;
                }
                else
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase + tunnChromaPhase;
                }
                stReg.reg =
                    0x0146;
                u8RegData = ((tunnChromaPhase >> 16) & 0x1f) | 0x20;
                if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
                   0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0147;
                u8RegData = (tunnChromaPhase >> 8) & 0xff;
                if((result
                    = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0148;
                u8RegData = (tunnChromaPhase) & 0xff;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                Print(
                    "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                    , slvAddr COMMA tunnChromaPhase);
                {
                    stReg.reg = 0x0154;
                    u8RegData = 0x0e;
                    if((result =
                            PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                    stReg.reg = 0x0154;
                    u8RegData = 0x0f;
                    if((result = PR2000_PageWrite(
                                     i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                }
                pstIsr->stJobProc.cntChromaLockTunn++;
                pstIsr->stJobProc.
                cntWait300MsecTime = 1;
                pstIsr->stJobProc.numJobStep = 6;
                result = pstIsr->stJobProc.
                         numJobStep;
                return(result);
            }
        }
    }
    if(pstIsr->stJobProc.numJobStep == 10)
    {
#ifdef SUPPORT_CEQ
        Dbg(
            "\x25\x78\x2d\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x35\x29" "\n"
            , slvAddr);
        PR2000_GetDetGainStatus(i2cFd, slvAddr, &pstIsr->stJobProc.
                                stDetGainStatus);
        PR2000_GetEQGain(i2cFd, slvAddr, &pstIsr->stJobProc.
                         stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.
                         stMeasureEqInfo);
        Dbg(
            "\x25\x78\x2d\x64\x63\x47\x61\x69\x6e\x3a\x30\x78\x25\x30\x34\x78" "\n", pstIsr->
            stJobProc.stDetGainStatus.dcGain);
        if(pstIsr->stJobProc.stDetGainStatus.dcGain ==
           0xffff)
        {
            pstIsr->stJobProc.stTunnFactor.stepDir = -1;
            if(PR2000_GetTunnEQGain(i2cFd,
                                    slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &
                                    pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x64\x63\x5f\x67\x61\x69\x6e\x20\x3d\x20\x30\x78\x46\x46\x46\x46\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x73\x74\x65\x70\x2e" "\n"
                    , slvAddr);
                PR2000_SetEQGain(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                                 pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.stMeasureEqInfo);
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 10;
                if(pstIsr->
                   stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc.
                    cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 11;
                    pstIsr->stJobProc.cntJobTry
                        = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 11;
                pstIsr->stJobProc
                .cntJobTry = 0;

            }
        }
        else if(pstIsr->stJobProc.stDetGainStatus.dcGain < 0x1300)
        {
            pstIsr->stJobProc.
            stTunnFactor.stepDir = -1;
            if(PR2000_SetTunnVADCGain(i2cFd, slvAddr, &pstIsr->
                                      stJobProc.stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.
                                      stTunnFactor, &pstIsr->stJobProc.stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x64\x63\x5f\x67\x61\x69\x6e\x20\x3c\x20\x30\x78\x31\x33\x30\x30\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x76\x61\x64\x63\x67\x61\x69\x6e\x2e" "\n"
                    , slvAddr);
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 10
                                               ;
                if(pstIsr->stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc
                    .cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 11;
                    pstIsr->stJobProc.
                    cntJobTry = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 11;
                pstIsr->stJobProc
                .cntJobTry = 0;

            }
        }
        else
        {
            Dbg(
                "\x25\x78\x2d\x45\x6e\x64\x20\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x35\x29" "\n"
                , slvAddr);
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->stJobProc.numJobStep = 11
                                           ;
            pstIsr->stJobProc.cntJobTry = 0;

        }
#else
        pstIsr->stJobProc.EQ_CNT = 2;
        pstIsr->stJobProc.C_LOCK_CNT = 1;
        pstIsr->stJobProc.
        cntWait300MsecTime = 0;
        pstIsr->stJobProc.numJobStep = 40;
        pstIsr->stJobProc.cntJobTry
            = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
#endif
    }
    if(pstIsr->stJobProc.numJobStep == 11)
    {
#ifdef SUPPORT_CEQ
        Dbg(
            "\x25\x78\x2d\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x35\x29" "\n"
            , slvAddr);
        PR2000_GetDetGainStatus(i2cFd, slvAddr, &pstIsr->stJobProc.
                                stDetGainStatus);
        PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.
                           stVidStatusReg, &cameraStandard, &cameraResolution, &videoResolution, &reJudge);
        if((
               pstIsr->stJobProc.stDetGainStatus.atten2 < 0x0500) || (pstIsr->stJobProc.
                       stDetGainStatus.acGain < 0x0700))
        {
            pstIsr->stJobProc.stTunnFactor.stepDir = -1;
            if(
                PR2000_SetTunnEQBand(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->
                                     stJobProc.stDetGainStatus, &pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.
                                     stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x61\x74\x74\x65\x6e\x32\x20\x3c\x20\x30\x78\x30\x35\x30\x30\x20\x6f\x72\x20\x61\x63\x47\x61\x69\x6e\x20\x3c\x20\x30\x78\x30\x37\x30\x30\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x62\x61\x6e\x64\x2e" "\n"
                    , slvAddr);
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 11
                                               ;
                if(pstIsr->stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc
                    .EQ_CNT = 2;
                    pstIsr->stJobProc.C_LOCK_CNT = 1;
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 40;
                    pstIsr->stJobProc.cntJobTry = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.EQ_CNT = 2;
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                pstIsr->stJobProc.
                cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 40;
                pstIsr->stJobProc.cntJobTry
                    = 0;

            }
        }
        else
        {
            uint16_t tmpAtten2 = 0;
            if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 1200)
                tmpAtten2 = 0x1d00;
            else if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 1000)
                tmpAtten2 = 0x1800;
            else if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 800)
                tmpAtten2 = 0x1600;
            else if((pstIsr->stJobProc.stMeasureEqInfo.distComp > 600) || (
                        cameraStandard == SD))tmpAtten2 = 0x1400;
            else tmpAtten2 = 0x1100;
            if(pstIsr->stJobProc.
               stDetGainStatus.atten2 > tmpAtten2)
            {
                pstIsr->stJobProc.stTunnFactor.stepDir = 1;
                if(
                    PR2000_SetTunnEQBand(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->
                                         stJobProc.stDetGainStatus, &pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.
                                         stMeasureEqInfo) > 0)
                {
                    Print(
                        "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                        , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                        stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                        COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                        stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                        pstIsr->stJobProc.stDetGainStatus.atten2);
                    Print(
                        "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x28\x64\x69\x73\x74\x43\x6f\x6d\x70\x3a\x25\x64\x2c\x25\x73\x29\x20\x26\x26\x20\x28\x61\x74\x74\x65\x6e\x32\x20\x3e\x20\x30\x78\x25\x30\x34\x78\x29\x2c\x20\x69\x6e\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x62\x61\x6e\x64\x2e" "\n"
                        , slvAddr COMMA pstIsr->stJobProc.stMeasureEqInfo.distComp COMMA(cameraStandard ==
                                SD) ? "\x53\x44" : "\x48\x44" COMMA tmpAtten2);
                    pstIsr->stJobProc.cntWait300MsecTime =
                        0;
                    pstIsr->stJobProc.numJobStep = 11;
                    if(pstIsr->stJobProc.cntJobTry++ >
                       MAX_PR2000_CEQ_COMP_TBL_NUM)
                    {
                        pstIsr->stJobProc.EQ_CNT = 2;
                        pstIsr->stJobProc.
                        C_LOCK_CNT = 1;
                        pstIsr->stJobProc.cntWait300MsecTime = 0;
                        pstIsr->stJobProc.numJobStep
                            = 40;
                        pstIsr->stJobProc.cntJobTry = 0;

                    }
                    else
                    {
                        result = pstIsr->stJobProc.numJobStep;
                        return(result);
                    }
                }
                else
                {
                    pstIsr->
                    stJobProc.EQ_CNT = 2;
                    pstIsr->stJobProc.C_LOCK_CNT = 1;
                    pstIsr->stJobProc.
                    cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 40;
                    pstIsr->stJobProc.cntJobTry
                        = 0;

                }
            }
            else
            {
                Dbg(
                    "\x25\x78\x2d\x45\x6e\x64\x20\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x35\x29" "\n"
                    , slvAddr);
                pstIsr->stJobProc.EQ_CNT = 2;
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 40;
                pstIsr->stJobProc
                .cntJobTry = 0;
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
        }
#else
        pstIsr->stJobProc.EQ_CNT = 2;
        pstIsr->stJobProc.C_LOCK_CNT = 1;
        pstIsr->stJobProc.
        cntWait300MsecTime = 0;
        pstIsr->stJobProc.numJobStep = 40;
        pstIsr->stJobProc.cntJobTry
            = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
#endif
    }
    if(pstIsr->stJobProc.numJobStep == 20)
    {
#ifdef SUPPORT_CEQ
        Dbg(
            "\x25\x78\x2d\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x36\x29" "\n"
            , slvAddr);
        PR2000_GetDetGainStatus(i2cFd, slvAddr, &pstIsr->stJobProc.
                                stDetGainStatus);
        PR2000_GetEQGain(i2cFd, slvAddr, &pstIsr->stJobProc.
                         stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.
                         stMeasureEqInfo);
        Dbg(
            "\x25\x78\x2d\x64\x63\x47\x61\x69\x6e\x3a\x30\x78\x25\x30\x34\x78" "\n", pstIsr->
            stJobProc.stDetGainStatus.dcGain);
        if(pstIsr->stJobProc.stDetGainStatus.dcGain ==
           0xffff)
        {
            pstIsr->stJobProc.stTunnFactor.stepDir = -1;
            if(PR2000_GetTunnEQGain(i2cFd,
                                    slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &
                                    pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x64\x63\x5f\x67\x61\x69\x6e\x20\x3d\x20\x30\x78\x46\x46\x46\x46\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x73\x74\x65\x70\x2e" "\n"
                    , slvAddr);
                PR2000_SetEQGain(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                                 pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.stMeasureEqInfo);
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 20;
                if(pstIsr->
                   stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc.
                    cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 21;
                    pstIsr->stJobProc.cntJobTry
                        = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 21;
                pstIsr->stJobProc
                .cntJobTry = 0;

            }
        }
        else if(pstIsr->stJobProc.stDetGainStatus.dcGain < 0x1300)
        {
            pstIsr->stJobProc.
            stTunnFactor.stepDir = -1;
            if(PR2000_SetTunnVADCGain(i2cFd, slvAddr, &pstIsr->
                                      stJobProc.stVidStatusReg, &pstIsr->stJobProc.stDetGainStatus, &pstIsr->stJobProc.
                                      stTunnFactor, &pstIsr->stJobProc.stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x64\x63\x5f\x67\x61\x69\x6e\x20\x3c\x20\x30\x78\x31\x33\x30\x30\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x76\x61\x64\x63\x67\x61\x69\x6e\x2e" "\n"
                    , slvAddr);
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 20
                                               ;
                if(pstIsr->stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc
                    .cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 21;
                    pstIsr->stJobProc.
                    cntJobTry = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 21;
                pstIsr->stJobProc
                .cntJobTry = 0;

            }
        }
        else
        {
            Dbg(
                "\x25\x78\x2d\x45\x6e\x64\x20\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x31\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x36\x29" "\n"
                , slvAddr);
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->stJobProc.numJobStep = 21
                                           ;
            pstIsr->stJobProc.cntJobTry = 0;

        }
#else
        pstIsr->stJobProc.EQ_CNT = 2;
        pstIsr->stJobProc.C_LOCK_CNT = 1;
        pstIsr->stJobProc.
        cntWait300MsecTime = 0;
        pstIsr->stJobProc.numJobStep = 40;
        pstIsr->stJobProc.cntJobTry
            = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
#endif
    }
    if(pstIsr->stJobProc.numJobStep == 21)
    {
#ifdef SUPPORT_CEQ
        Dbg(
            "\x25\x78\x2d\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x36\x29" "\n"
            , slvAddr);
        PR2000_GetDetGainStatus(i2cFd, slvAddr, &pstIsr->stJobProc.
                                stDetGainStatus);
        PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.
                           stVidStatusReg, &cameraStandard, &cameraResolution, &videoResolution, &reJudge);
        if((
               pstIsr->stJobProc.stDetGainStatus.atten2 < 0x0500) || (pstIsr->stJobProc.
                       stDetGainStatus.acGain < 0x0700))
        {
            pstIsr->stJobProc.stTunnFactor.stepDir = -1;
            if(
                PR2000_SetTunnEQBand(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->
                                     stJobProc.stDetGainStatus, &pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.
                                     stMeasureEqInfo) > 0)
            {
                Print(
                    "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                    stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                    COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                    stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                    pstIsr->stJobProc.stDetGainStatus.atten2);
                Print(
                    "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x61\x74\x74\x65\x6e\x32\x20\x3c\x20\x30\x78\x30\x35\x30\x30\x20\x6f\x72\x20\x61\x63\x47\x61\x69\x6e\x20\x3c\x20\x30\x78\x30\x37\x30\x30\x2c\x20\x64\x65\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x62\x61\x6e\x64\x2e" "\n"
                    , slvAddr);
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 21
                                               ;
                if(pstIsr->stJobProc.cntJobTry++ > MAX_PR2000_CEQ_COMP_TBL_NUM)
                {
                    pstIsr->stJobProc
                    .EQ_CNT = 2;
                    pstIsr->stJobProc.C_LOCK_CNT = 1;
                    pstIsr->stJobProc.cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 40;
                    pstIsr->stJobProc.cntJobTry = 0;

                }
                else
                {
                    result = pstIsr->stJobProc.numJobStep;
                    return(result);
                }
            }
            else
            {
                pstIsr->
                stJobProc.EQ_CNT = 2;
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                pstIsr->stJobProc.
                cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 40;
                pstIsr->stJobProc.cntJobTry
                    = 0;

            }
        }
        else
        {
            uint16_t tmpAtten2 = 0;
            if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 1200)
                tmpAtten2 = 0x1d00;
            else if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 1000)
                tmpAtten2 = 0x1800;
            else if(pstIsr->stJobProc.stMeasureEqInfo.distComp > 800)
                tmpAtten2 = 0x1600;
            else if((pstIsr->stJobProc.stMeasureEqInfo.distComp > 600) || (
                        cameraStandard == SD))tmpAtten2 = 0x1400;
            else tmpAtten2 = 0x1100;
            if(pstIsr->stJobProc.
               stDetGainStatus.atten2 > tmpAtten2)
            {
                pstIsr->stJobProc.stTunnFactor.stepDir = 1;
                if(
                    PR2000_SetTunnEQBand(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &pstIsr->
                                         stJobProc.stDetGainStatus, &pstIsr->stJobProc.stTunnFactor, &pstIsr->stJobProc.
                                         stMeasureEqInfo) > 0)
                {
                    Print(
                        "\x25\x78\x2d\x20\x20\x5b\x73\x79\x6e\x63\x4c\x65\x76\x65\x6c\x3a\x25\x30\x32\x78\x2c\x20\x64\x63\x3a\x25\x30\x34\x78\x2c\x20\x61\x63\x3a\x25\x30\x34\x78\x2c\x20\x63\x6f\x6d\x70\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x2c\x20\x61\x74\x74\x65\x6e\x5b\x25\x30\x34\x78\x2c\x20\x25\x30\x34\x78\x5d\x5d" "\n"
                        , slvAddr COMMA pstIsr->stJobProc.stDetGainStatus.syncLevel COMMA pstIsr->
                        stJobProc.stDetGainStatus.dcGain COMMA pstIsr->stJobProc.stDetGainStatus.acGain
                        COMMA pstIsr->stJobProc.stDetGainStatus.comp1 COMMA pstIsr->stJobProc.
                        stDetGainStatus.comp2 COMMA pstIsr->stJobProc.stDetGainStatus.atten1 COMMA
                        pstIsr->stJobProc.stDetGainStatus.atten2);
                    Print(
                        "\x25\x78\x2d\x20\x20\x45\x71\x20\x66\x69\x6e\x65\x20\x74\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x28\x64\x69\x73\x74\x43\x6f\x6d\x70\x3a\x25\x64\x2c\x25\x73\x29\x20\x26\x26\x20\x28\x61\x74\x74\x65\x6e\x32\x20\x3e\x20\x30\x78\x25\x30\x34\x78\x29\x2c\x20\x69\x6e\x63\x72\x65\x61\x73\x65\x20\x45\x71\x20\x62\x61\x6e\x64\x2e" "\n"
                        , slvAddr COMMA pstIsr->stJobProc.stMeasureEqInfo.distComp COMMA(cameraStandard ==
                                SD) ? "\x53\x44" : "\x48\x44" COMMA tmpAtten2);
                    pstIsr->stJobProc.cntWait300MsecTime =
                        0;
                    pstIsr->stJobProc.numJobStep = 21;
                    if(pstIsr->stJobProc.cntJobTry++ >
                       MAX_PR2000_CEQ_COMP_TBL_NUM)
                    {
                        pstIsr->stJobProc.EQ_CNT = 2;
                        pstIsr->stJobProc.
                        C_LOCK_CNT = 1;
                        pstIsr->stJobProc.cntWait300MsecTime = 0;
                        pstIsr->stJobProc.numJobStep
                            = 40;
                        pstIsr->stJobProc.cntJobTry = 0;

                    }
                    else
                    {
                        result = pstIsr->stJobProc.numJobStep;
                        return(result);
                    }
                }
                else
                {
                    pstIsr->
                    stJobProc.EQ_CNT = 2;
                    pstIsr->stJobProc.C_LOCK_CNT = 1;
                    pstIsr->stJobProc.
                    cntWait300MsecTime = 0;
                    pstIsr->stJobProc.numJobStep = 40;
                    pstIsr->stJobProc.cntJobTry
                        = 0;

                }
            }
            else
            {
                Dbg(
                    "\x25\x78\x2d\x45\x6e\x64\x20\x45\x51\x20\x46\x69\x6e\x65\x20\x54\x75\x6e\x6e\x69\x6e\x67\x2d\x32\x20\x66\x72\x6f\x6d\x20\x6e\x75\x6d\x4a\x6f\x62\x28\x36\x29" "\n"
                    , slvAddr);
                pstIsr->stJobProc.EQ_CNT = 2;
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                pstIsr->
                stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 40;
                pstIsr->stJobProc
                .cntJobTry = 0;
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
        }
#else
        pstIsr->stJobProc.EQ_CNT = 2;
        pstIsr->stJobProc.C_LOCK_CNT = 1;
        pstIsr->stJobProc.
        cntWait300MsecTime = 0;
        pstIsr->stJobProc.numJobStep = 40;
        pstIsr->stJobProc.cntJobTry
            = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
#endif
    }
    if(pstIsr->stJobProc.numJobStep == 30)
    {
        Print("\x25\x78\x2d\x41\x62\x6e\x6f\x72\x6d\x61\x6c\x20\x63\x61\x73\x65" "\n",
              slvAddr);
        Print(
            "\x25\x78\x2d\x46\x6f\x72\x63\x65\x6c\x79\x20\x53\x65\x74\x20\x61\x62\x6e\x6f\x72\x6d\x61\x6c\x20\x53\x54\x44\x28\x43\x56\x49\x29" "\n"
            , slvAddr);
        pstIsr->stJobProc.stVidStatusReg.b.det_ifmt_std = DET_CVI;
        PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                           cameraStandard, &cameraResolution, &videoResolution, &reJudge);
        reJudge = 1;
        pstIsr->
        stJobProc.reJudgeStdResol = reJudge;
        Print(
            "\x25\x78\x2d\x66\x6f\x72\x6d\x61\x74\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x20\x72\x65\x4a\x75\x64\x67\x65\x3a\x25\x64\x5d" "\n"
            , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
            cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
            videoResolution COMMA _strVideoResolution[videoResolution]COMMA reJudge);
        Print(
            "\x25\x78\x2d\x53\x65\x74\x20\x6f\x6e\x6c\x79\x20\x53\x74\x52\x65\x73\x6f\x6c\x2c\x20\x45\x71\x47\x61\x69\x6e\x2c\x20\x43\x50\x68\x61\x73\x65\x52\x65\x66\x28\x6b\x65\x65\x70\x29\x2e\x2e\x2e" "\n"
            , slvAddr);
        if((result = PR2000_SetTblBrief(i2cFd, slvAddr, cameraStandard, videoResolution, 0, &
                                        pstIsr->stJobProc)) < 0)
        {
            ErrorString(
                "\x43\x61\x6e\x27\x74\x20\x73\x65\x74\x20\x74\x61\x62\x6c\x65\x20\x62\x72\x69\x65\x66" "\n"
            );
            return(result);
        }
        pstIsr->stJobProc.cntWait300MsecTime = 0;
        pstIsr->stJobProc.
        numJobStep = 40;
        pstIsr->stJobProc.cntJobTry = 0;
        result = pstIsr->stJobProc.numJobStep;
        return(result);
    }
    if(pstIsr->stJobProc.numJobStep == 40)
    {
        if(!DEFAULT_AUTODETECT_ENABLE)
        {
            PR2000_ReadStdResol(i2cFd, slvAddr, &pstIsr->
                                stJobProc.stVidStatusReg, &cameraStandard, &cameraResolution, &videoResolution);
            pstIsr->stJobProc.reJudgeStdResol = TRUE;
            if((cameraStandard == HDT_NEW) && ((
                                                   cameraResolution == camera_1280x720p25) || (cameraResolution == camera_1280x720p30)))
            {
                if((pstIsr->stJobProc.stVidStatusReg.b.det_std_hdt_v == 1) && (pstIsr->stJobProc.
                        stVidStatusReg.b.det_std_hdt_h1 == 1) && (pstIsr->stJobProc.stVidStatusReg.b.
                                det_std_hdt_h0 == 1))
                {
                    cameraStandard = HDT_NEW;
                }
                else if((pstIsr->stJobProc.
                         stVidStatusReg.b.det_std_hdt_v == 1) && (pstIsr->stJobProc.stVidStatusReg.b.
                                 det_std_hdt_h1 == 0) && (pstIsr->stJobProc.stVidStatusReg.b.det_std_hdt_h0 == 1))
                {
                    cameraStandard = HDT_OLD;
                }
            }
            Print(
                "\x25\x78\x2d\x46\x69\x78\x20\x53\x65\x74\x20\x66\x69\x6e\x61\x6c\x20\x76\x64\x65\x63\x20\x66\x6f\x72\x6d\x61\x74\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x20\x72\x65\x4a\x75\x64\x67\x65\x3a\x25\x64\x5d" "\n"
                , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                videoResolution COMMA _strVideoResolution[videoResolution]COMMA pstIsr->
                stJobProc.reJudgeStdResol);
        }
        else
        {
            if(PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->
                                  stJobProc.stVidStatusReg, &cameraStandard, &cameraResolution, &videoResolution, &
                                  reJudge) < 0)
            {
                Error(
                    "\x25\x78\x2d\x49\x6e\x76\x61\x6c\x69\x64\x20\x53\x74\x64\x52\x65\x73\x6f\x6c\x2e\x20\x52\x65\x63\x68\x65\x63\x6b\x2e" "\n"
                    , slvAddr);
                memset(&pstIsr->stJobProc, 0, sizeof(_stJobProc));
                PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
                memcpy(&pstIsr->
                       stJobProc.stStartVidStatusReg, &curStVidStatusReg, sizeof(_stPR2000_VidStatusReg))
                ;
                memcpy(&pstIsr->stJobProc.stVidStatusReg, &curStVidStatusReg, sizeof(
                           _stPR2000_VidStatusReg));
                _SET_BIT(JOB_START_CAMERA_IN, &pstIsr->stJobProc.
                         bitJobProcess);
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.
                numJobStep = 1;
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
            if(pstIsr->
               stJobProc.reJudgeStdResol == 0)
            {
                pstIsr->stJobProc.reJudgeStdResol = reJudge;
            }
            Print(
                "\x25\x78\x2d\x53\x65\x74\x20\x66\x69\x6e\x61\x6c\x20\x76\x64\x65\x63\x20\x66\x6f\x72\x6d\x61\x74\x5b\x43\x61\x6d\x65\x72\x61\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x63\x61\x6d\x65\x72\x61\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x2c\x20\x76\x69\x64\x65\x6f\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3a\x25\x64\x28\x25\x73\x29\x20\x72\x65\x4a\x75\x64\x67\x65\x3a\x25\x64\x5d" "\n"
                , slvAddr COMMA cameraStandard COMMA _strCameraStandard[cameraStandard]COMMA
                cameraResolution COMMA _strCameraResolution[cameraResolution]COMMA
                videoResolution COMMA _strVideoResolution[videoResolution]COMMA pstIsr->
                stJobProc.reJudgeStdResol);
        }
#ifdef SUPPORT_AUTOSET_VIDEO
        PR2000_SetTableStdResol(i2cFd, slvAddr, cameraStandard, videoResolution);
#ifdef SUPPORT_AUTOSET_VIDOUT_DATARATE_LANE
        for(chipInx = 0; chipInx < gFindPr2000SlvAddrCnt; chipInx++)
        {
            if(PR2000_ATTR_CHIP[
                   chipInx].i2cSlvAddr == slvAddr)
            {
                break;
            }
        }
        if(PR2000_ATTR_CHIP[chipInx].vidOutMode == 0
          )
        {
#ifdef SUPPORT_SD_VIDEO_960H_RESOLUTION
            if(videoResolution <= video_960x576i50)
            {
                PR2000_ATTR_CHIP[chipInx].datarate = 2;
            }
            else
            {
                if((videoResolution == video_1280x720p30) || (videoResolution ==
                        video_1280x720p25))
                {
                    PR2000_ATTR_CHIP[chipInx].datarate = 1;
                }
                else
                {
                    PR2000_ATTR_CHIP[chipInx].datarate = 0;
                }
            }
#else
            if(videoResolution <= video_960x576i50)
            {
                PR2000_ATTR_CHIP[chipInx].datarate = 3;
            }
            else
            {
                if((videoResolution == video_1280x720p30) || (videoResolution ==
                        video_1280x720p25))
                {
                    PR2000_ATTR_CHIP[chipInx].datarate = 1;
                }
                else
                {
                    PR2000_ATTR_CHIP[chipInx].datarate = 0;
                }
            }
#endif
        }
        else
        {
            if(videoResolution <= video_960x576i50)
            {
                PR2000_ATTR_CHIP[chipInx].vidOutMode = 2;
            }
            else
            {
                if((videoResolution == video_1280x720p30) || (videoResolution ==
                        video_1280x720p25))
                {
                    PR2000_ATTR_CHIP[chipInx].vidOutMode = 2;
                }
                else
                {
                    PR2000_ATTR_CHIP[chipInx].vidOutMode = 4;
                }
            }
        }
        PR2000_SetAttrChip(i2cFd, slvAddr, &PR2000_ATTR_CHIP[chipInx]);
#endif
#endif
        if(pstIsr->stJobProc.reJudgeStdResol)
        {
            Print(
                "\x25\x78\x2d\x53\x74\x6f\x70\x20\x56\x46\x44\x20\x69\x72\x71\x2e\x20\x62\x65\x63\x61\x73\x75\x65\x20\x6f\x66\x20\x72\x65\x6a\x75\x64\x67\x65\x20\x66\x6c\x61\x67\x2e" "\n"
                , slvAddr);
            {
                stReg.reg = 0x0091;
                u8RegMask = 0x20;
                u8RegData = 0x00;
                if((result =
                        PR2000_PageWriteMaskBit(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegMask,
                                                u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
            Print(
                "\x25\x78\x2d\x53\x65\x74\x20\x4d\x61\x6e\x75\x61\x6c\x20\x53\x74\x64" "\n",
                slvAddr);
            {
                stReg.reg = 0x0011;
                u8RegMask = 0x04;
                u8RegData = 0x04;
                if((result =
                        PR2000_PageWriteMaskBit(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegMask,
                                                u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
        }
        else
        {
            Print(
                "\x25\x78\x2d\x53\x74\x61\x72\x74\x20\x56\x46\x44\x20\x69\x72\x71" "\n", slvAddr)
            ;
            {
                stReg.reg = 0x0091;
                u8RegMask = 0x20;
                u8RegData = 0x20;
                if((result =
                        PR2000_PageWriteMaskBit(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegMask,
                                                u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
        }
#ifdef SUPPORT_UTC
        PR2000_UTC_SetTable(i2cFd, slvAddr, cameraStandard, cameraResolution);
#endif
#ifdef SUPPORT_OSG
        PR2000_OSG_SetTable(i2cFd, slvAddr, cameraStandard, videoResolution);
#endif
#ifdef SUPPORT_FPGA
        PR2000_FPGA_SetTable(i2cFd, slvAddr);
#endif
        if(!DEFAULT_AUTODETECT_ENABLE)
        {
            pstIsr->stJobProc.C_LOCK_CNT = 1;
            pstIsr->stJobProc.
            AC_GAIN_ADJ = 0;
            pstIsr->stJobProc.AC_GAIN_HOLD = 0;
            pstIsr->stJobProc.EQ_CNT = 2;
            pstIsr
            ->stJobProc.cntWait300MsecTime = 0;
            pstIsr->stJobProc.numJobStep = 50;
            pstIsr->
            stJobProc.cntJobTry = 0;
            _SET_BIT(JOB_DONE_CAMERA_IN, &pstIsr->stJobProc.
                     bitJobProcess);
            _SET_BIT(JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.
                     bitJobProcess);
            Dbg(
                "\x53\x65\x74\x20\x75\x73\x65\x72\x20\x66\x6c\x61\x67\x28\x25\x64\x2c\x25\x64\x2c\x25\x64\x29" "\n"
                , cameraStandard COMMA cameraResolution COMMA videoResolution);
            pHost->stPrRxMode.
            standard = cameraStandard;
            pHost->stPrRxMode.cameraResolution = cameraResolution;
            pHost->stPrRxMode.vidOutResolution = videoResolution;
            _SET_BIT(IRQ_SET_RXMODE, &
                     pstIsr->stUserPoll.bitIrq);
            _SET_BIT(IRQ_SET_RXMODE, &pstIsr->stUserPoll.
                     bitIrqStatus);
            Print(
                "\x25\x78\x2d\x46\x69\x78\x20\x67\x6f\x20\x6e\x6f\x72\x6d\x61\x6c\x20\x6d\x6f\x6e\x69\x74\x6f\x72\x20\x70\x72\x6f\x63\x65\x73\x73\x69\x6e\x67\x28\x43\x5f\x64\x65\x74\x20\x26\x20\x43\x5f\x6c\x6f\x63\x6b\x29" "\n"
                , slvAddr);
            result = pstIsr->stJobProc.numJobStep;
            return(result);
        }
        else
        {
            PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
            Dbg(
                "\x25\x78\x2d\x43\x75\x72\x20\x56\x69\x64\x53\x74\x61\x74\x75\x73\x3a\x30\x78\x25\x30\x32\x78\x25\x30\x32\x78\x25\x30\x32\x78" "\n"
                , slvAddr COMMA curStVidStatusReg.reg[0]COMMA curStVidStatusReg.reg[1]COMMA
                curStVidStatusReg.reg[2]);
            if((curStVidStatusReg.b.det_chroma) && (
                   curStVidStatusReg.b.lock_chroma))
            {
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                pstIsr->
                stJobProc.AC_GAIN_ADJ = 0;
                pstIsr->stJobProc.AC_GAIN_HOLD = 0;
                if(pstIsr->stJobProc.
                   EQ_CNT == 0)
                {
                    pstIsr->stJobProc.EQ_CNT = 1;
                }
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 50;
                pstIsr->stJobProc.cntJobTry = 0;
                _SET_BIT(
                    JOB_DONE_CAMERA_IN, &pstIsr->stJobProc.bitJobProcess);
                _SET_BIT(
                    JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.bitJobProcess);
                Dbg(
                    "\x53\x65\x74\x20\x75\x73\x65\x72\x20\x66\x6c\x61\x67\x28\x25\x64\x2c\x25\x64\x2c\x25\x64\x29" "\n"
                    , cameraStandard COMMA cameraResolution COMMA videoResolution);
                pHost->stPrRxMode.
                standard = cameraStandard;
                pHost->stPrRxMode.cameraResolution = cameraResolution;
                pHost->stPrRxMode.vidOutResolution = videoResolution;
                _SET_BIT(IRQ_SET_RXMODE, &
                         pstIsr->stUserPoll.bitIrq);
                _SET_BIT(IRQ_SET_RXMODE, &pstIsr->stUserPoll.
                         bitIrqStatus);
                Print(
                    "\x25\x78\x2d\x67\x6f\x20\x6e\x6f\x72\x6d\x61\x6c\x20\x6d\x6f\x6e\x69\x74\x6f\x72\x20\x70\x72\x6f\x63\x65\x73\x73\x69\x6e\x67\x28\x43\x5f\x64\x65\x74\x20\x26\x20\x43\x5f\x6c\x6f\x63\x6b\x29" "\n"
                    , slvAddr);
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
            else if((
                        curStVidStatusReg.b.det_chroma) && (!curStVidStatusReg.b.lock_chroma))
            {
                pstIsr->
                stJobProc.cntChromaLockTunn = 0;
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->
                stJobProc.numJobStep = 41;
                pstIsr->stJobProc.cntJobTry = 0;
                Print(
                    "\x25\x78\x2d\x67\x6f\x20\x61\x62\x6e\x6f\x72\x6d\x61\x6c\x20\x70\x72\x6f\x63\x65\x73\x73\x69\x6e\x67\x28\x43\x5f\x44\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b\x29" "\n"
                    , slvAddr);
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
            else if((!
                     curStVidStatusReg.b.det_chroma))
            {
                pstIsr->stJobProc.C_LOCK_CNT = 0;
                pstIsr->
                stJobProc.AC_GAIN_ADJ = 0;
                pstIsr->stJobProc.AC_GAIN_HOLD = 0;
                if(pstIsr->stJobProc.
                   EQ_CNT == 0)
                {
                    pstIsr->stJobProc.EQ_CNT = 1;
                }
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 50;
                pstIsr->stJobProc.cntJobTry = 0;
                _SET_BIT(
                    JOB_DONE_CAMERA_IN, &pstIsr->stJobProc.bitJobProcess);
                _SET_BIT(
                    JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.bitJobProcess);
                Dbg(
                    "\x53\x65\x74\x20\x75\x73\x65\x72\x20\x66\x6c\x61\x67\x28\x25\x64\x2c\x25\x64\x2c\x25\x64\x29" "\n"
                    , cameraStandard COMMA cameraResolution COMMA videoResolution);
                pHost->stPrRxMode.
                standard = cameraStandard;
                pHost->stPrRxMode.cameraResolution = cameraResolution;
                pHost->stPrRxMode.vidOutResolution = videoResolution;
                _SET_BIT(IRQ_SET_RXMODE, &
                         pstIsr->stUserPoll.bitIrq);
                _SET_BIT(IRQ_SET_RXMODE, &pstIsr->stUserPoll.
                         bitIrqStatus);
                Print(
                    "\x25\x78\x2d\x67\x6f\x20\x61\x62\x6e\x6f\x72\x6d\x61\x6c\x20\x6d\x6f\x6e\x69\x74\x6f\x72\x20\x70\x72\x6f\x63\x65\x73\x73\x69\x6e\x67\x28\x21\x43\x5f\x64\x65\x74\x29" "\n"
                    , slvAddr);
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
        }
    }
    if(pstIsr->
       stJobProc.numJobStep == 41)
    {
        Print(
            "\x25\x78\x2d\x43\x68\x65\x63\x6b\x20\x31\x27\x73\x74\x20\x43\x5f\x64\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b" "\n"
            , slvAddr);
        PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
        PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                           cameraStandard, &cameraResolution, &videoResolution, &reJudge);
        if((
               curStVidStatusReg.b.det_chroma) && (curStVidStatusReg.b.lock_chroma))
        {
            pstIsr->
            stJobProc.C_LOCK_CNT = 1;
            Print(
                "\x25\x78\x2d\x66\x69\x6e\x64\x20\x76\x61\x6c\x69\x64\x20\x63\x68\x72\x6f\x6d\x61\x20\x6c\x6f\x63\x6b" "\n"
                , slvAddr);
            pstIsr->stJobProc.AC_GAIN_ADJ = 0;
            pstIsr->stJobProc.AC_GAIN_HOLD = 0;
            if(
                pstIsr->stJobProc.EQ_CNT == 0)
            {
                pstIsr->stJobProc.EQ_CNT = 1;
            }
            pstIsr->stJobProc.
            cntChromaLockTunn = 0;
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->stJobProc.
            numJobStep = 50;
            pstIsr->stJobProc.cntJobTry = 0;
            _SET_BIT(JOB_DONE_CAMERA_IN, &pstIsr
                     ->stJobProc.bitJobProcess);
            _SET_BIT(JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.
                     bitJobProcess);
            Dbg(
                "\x53\x65\x74\x20\x75\x73\x65\x72\x20\x66\x6c\x61\x67\x28\x25\x64\x2c\x25\x64\x2c\x25\x64\x29" "\n"
                , cameraStandard COMMA cameraResolution COMMA videoResolution);
            pHost->stPrRxMode.
            standard = cameraStandard;
            pHost->stPrRxMode.cameraResolution = cameraResolution;
            pHost->stPrRxMode.vidOutResolution = videoResolution;
            _SET_BIT(IRQ_SET_RXMODE, &
                     pstIsr->stUserPoll.bitIrq);
            _SET_BIT(IRQ_SET_RXMODE, &pstIsr->stUserPoll.
                     bitIrqStatus);
            result = pstIsr->stJobProc.numJobStep;
            return(result);
        }
        else if((
                    curStVidStatusReg.b.det_chroma) && (!curStVidStatusReg.b.lock_chroma))
        {
            pstIsr->
            stJobProc.C_LOCK_CNT = 0;
            {
                stReg.reg = 0x0146;
                if((result = PR2000_PageRead(i2cFd,
                                             slvAddr, stReg.b.page, stReg.b.addr, &u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x72\x65\x61\x64" "\n");
                    return(result);
                }
                pstIsr->stJobProc.defChromaPhase = (uint32_t)(u8RegData & 0x1f) << 16;
                stReg.reg = 0x0147;
                if((result = PR2000_PageRead(i2cFd, slvAddr, stReg.b.page, stReg.b.
                                             addr, &u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x72\x65\x61\x64" "\n");
                    return(result);
                }
                pstIsr->stJobProc.defChromaPhase |= (uint32_t)(u8RegData & 0xff) << 8;
                stReg.reg = 0x0148;
                if((result = PR2000_PageRead(i2cFd, slvAddr, stReg.b.page, stReg.b.
                                             addr, &u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x72\x65\x61\x64" "\n");
                    return(result);
                }
                pstIsr->stJobProc.defChromaPhase |= (uint32_t)(u8RegData & 0xff);
                Print(
                    "\x25\x78\x2d\x62\x61\x73\x65\x20\x43\x50\x68\x61\x73\x65\x52\x65\x66\x42\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                    , slvAddr COMMA pstIsr->stJobProc.defChromaPhase);
            }
            pstIsr->stJobProc.
            cntChromaLockTunn = 0;
            pstIsr->stJobProc.cntWait300MsecTime = 0;
            pstIsr->stJobProc.
            numJobStep = 42;
            pstIsr->stJobProc.cntJobTry = 0;
            result = pstIsr->stJobProc.numJobStep;
            return(result);
        }
    }
    if(pstIsr->stJobProc.numJobStep == 42)
    {
        Print(
            "\x25\x78\x2d\x43\x68\x65\x63\x6b\x20\x32\x27\x6e\x64\x20\x43\x5f\x64\x65\x74\x20\x26\x20\x21\x43\x5f\x6c\x6f\x63\x6b\x20\x63\x68\x65\x63\x6b\x20\x61\x6e\x64\x20\x74\x75\x6e\x6e\x20\x63\x5f\x6c\x6f\x63\x6b\x2e" "\n"
            , slvAddr);
        Print(
            "\x25\x78\x2d\x64\x65\x66\x43\x68\x72\x6f\x6d\x61\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78\x2c\x20\x63\x6e\x74\x54\x75\x6e\x6e\x3a\x25\x78" "\n"
            , slvAddr COMMA pstIsr->stJobProc.defChromaPhase COMMA pstIsr->stJobProc.
            cntChromaLockTunn);
        PR2000_ReadVidStatusReg(i2cFd, slvAddr, &curStVidStatusReg);
        PR2000_GetStdResol(i2cFd, slvAddr, &pstIsr->stJobProc.stVidStatusReg, &
                           cameraStandard, &cameraResolution, &videoResolution, &reJudge);
        if((!
            curStVidStatusReg.b.det_chroma) || (pstIsr->stJobProc.cntChromaLockTunn >=
                                                MAX_CNT_TUNN_CHROMALOCK))
        {
            Error(
                "\x43\x61\x6e\x27\x74\x20\x44\x65\x74\x20\x63\x68\x72\x6f\x6d\x61\x28\x25\x64\x29\x20\x6f\x72\x20\x4f\x76\x65\x72\x20\x63\x68\x65\x63\x6b\x20\x74\x69\x6d\x65\x28\x25\x64\x29\x20\x63\x68\x72\x6f\x6d\x61\x20\x6c\x6f\x63\x6b\x2e" "\n"
                , curStVidStatusReg.b.det_chroma COMMA pstIsr->stJobProc.cntChromaLockTunn);
            tunnChromaPhase = pstIsr->stJobProc.defChromaPhase;
            stReg.reg = 0x0146;
            u8RegData = ((
                             tunnChromaPhase >> 16) & 0x1f) | 0x00;
            if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
               0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0147;
            u8RegData = (tunnChromaPhase >> 8) & 0xff;
            if((result
                = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            stReg.reg = 0x0148;
            u8RegData = (tunnChromaPhase) & 0xff;
            if((result =
                    PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
            {
                ErrorString(
                    "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                ;
                return(result);
            }
            Print(
                "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                , slvAddr COMMA tunnChromaPhase);
            {
                stReg.reg = 0x0154;
                u8RegData = 0x0e;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0154;
                u8RegData = 0x0f;
                if((result = PR2000_PageWrite(
                                 i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
            }
            if(!curStVidStatusReg.b.det_chroma)
            {
                pstIsr->stJobProc.
                AC_GAIN_ADJ = 0;
                pstIsr->stJobProc.AC_GAIN_HOLD = 0;
                if(pstIsr->stJobProc.EQ_CNT == 0)
                {
                    pstIsr->stJobProc.EQ_CNT = 1;
                }
                pstIsr->stJobProc.reJudgeStdResol = 1;
                pstIsr->
                stJobProc.cntChromaLockTunn = 0;
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->
                stJobProc.numJobStep = 50;
                pstIsr->stJobProc.cntJobTry = 0;
                _SET_BIT(
                    JOB_DONE_CAMERA_IN, &pstIsr->stJobProc.bitJobProcess);
                _SET_BIT(
                    JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.bitJobProcess);
                result = pstIsr->
                         stJobProc.numJobStep;
                return(result);
            }
            else
            {
                pstIsr->stJobProc.AC_GAIN_ADJ = 0;
                pstIsr
                ->stJobProc.AC_GAIN_HOLD = 0;
                if(pstIsr->stJobProc.EQ_CNT == 0)
                {
                    pstIsr->stJobProc.
                    EQ_CNT = 1;
                }
                pstIsr->stJobProc.cntChromaLockTunn = 0;
                pstIsr->stJobProc.
                cntWait300MsecTime = 0;
                pstIsr->stJobProc.numJobStep = 50;
                pstIsr->stJobProc.cntJobTry
                    = 0;
                _SET_BIT(JOB_DONE_CAMERA_IN, &pstIsr->stJobProc.bitJobProcess);
                _SET_BIT(
                    JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.bitJobProcess);
                result = pstIsr->
                         stJobProc.numJobStep;
                return(result);
            }
        }
        else if(pstIsr->stJobProc.
                cntChromaLockTunn < MAX_CNT_TUNN_CHROMALOCK)
        {
            if((curStVidStatusReg.b.det_chroma) &&
               (curStVidStatusReg.b.lock_chroma))
            {
                pstIsr->stJobProc.C_LOCK_CNT = 1;
                Print(
                    "\x25\x78\x2d\x66\x69\x6e\x64\x20\x76\x61\x6c\x69\x64\x20\x63\x68\x72\x6f\x6d\x61\x20\x6c\x6f\x63\x6b" "\n"
                    , slvAddr);
                pstIsr->stJobProc.AC_GAIN_ADJ = 0;
                pstIsr->stJobProc.AC_GAIN_HOLD = 0;
                if(
                    pstIsr->stJobProc.EQ_CNT == 0)
                {
                    pstIsr->stJobProc.EQ_CNT = 1;
                }
                pstIsr->stJobProc.
                cntChromaLockTunn = 0;
                pstIsr->stJobProc.cntWait300MsecTime = 0;
                pstIsr->stJobProc.
                numJobStep = 50;
                pstIsr->stJobProc.cntJobTry = 0;
                _SET_BIT(JOB_DONE_CAMERA_IN, &pstIsr
                         ->stJobProc.bitJobProcess);
                _SET_BIT(JOB_START_CAMERA_MONITOR, &pstIsr->stJobProc.
                         bitJobProcess);
                Dbg(
                    "\x53\x65\x74\x20\x75\x73\x65\x72\x20\x66\x6c\x61\x67\x28\x25\x64\x2c\x25\x64\x2c\x25\x64\x29" "\n"
                    , cameraStandard COMMA cameraResolution COMMA videoResolution);
                pHost->stPrRxMode.
                standard = cameraStandard;
                pHost->stPrRxMode.cameraResolution = cameraResolution;
                pHost->stPrRxMode.vidOutResolution = videoResolution;
                _SET_BIT(IRQ_SET_RXMODE, &
                         pstIsr->stUserPoll.bitIrq);
                _SET_BIT(IRQ_SET_RXMODE, &pstIsr->stUserPoll.
                         bitIrqStatus);
                result = pstIsr->stJobProc.numJobStep;
                return(result);
            }
            else if((
                        curStVidStatusReg.b.det_chroma) && (!curStVidStatusReg.b.lock_chroma))
            {
                tunnChromaPhase = (pstIsr->stJobProc.cntChromaLockTunn >> 1) + 1;
                tunnChromaPhase *= 40;
                if(pstIsr->stJobProc.cntChromaLockTunn & 1)
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase - tunnChromaPhase;
                }
                else
                {
                    tunnChromaPhase = pstIsr->stJobProc.defChromaPhase + tunnChromaPhase;
                }
                stReg.reg =
                    0x0146;
                u8RegData = ((tunnChromaPhase >> 16) & 0x1f) | 0x20;
                if((result = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) <
                   0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0147;
                u8RegData = (tunnChromaPhase >> 8) & 0xff;
                if((result
                    = PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                stReg.reg = 0x0148;
                u8RegData = (tunnChromaPhase) & 0xff;
                if((result =
                        PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                {
                    ErrorString(
                        "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                    ;
                    return(result);
                }
                Print(
                    "\x25\x78\x2d\x54\x75\x6e\x6e\x20\x43\x50\x68\x61\x73\x65\x3a\x30\x78\x25\x30\x38\x78" "\n"
                    , slvAddr COMMA tunnChromaPhase);
                {
                    stReg.reg = 0x0154;
                    u8RegData = 0x0e;
                    if((result =
                            PR2000_PageWrite(i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                    stReg.reg = 0x0154;
                    u8RegData = 0x0f;
                    if((result = PR2000_PageWrite(
                                     i2cFd, slvAddr, stReg.b.page, stReg.b.addr, u8RegData)) < 0)
                    {
                        ErrorString(
                            "\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x67\x65\x20\x77\x72\x69\x74\x65" "\n")
                        ;
                        return(result);
                    }
                }
                pstIsr->stJobProc.cntChromaLockTunn++;
                pstIsr->stJobProc.
                cntWait300MsecTime = 1;
                pstIsr->stJobProc.numJobStep = 42;
                result = pstIsr->stJobProc.
                         numJobStep;
                return(result);
            }
        }
    }
    return(result);
}

